#include <stdio.h>
#define max(a,b) (((a) > (b)) ? (a) : (b))

void move_right(int *input, int age, int max_index)
{
    int move = age - input[max_index + 1];
    input[max_index] -= move;
    input[max_index + 1] += move;
}

void move_left(int *input, int age, int max_index)
{
    int move = age - input[max_index - 1];
    input[max_index] -= move;
    input[max_index - 1] += move;
}

int main(int argc, char const *argv[])
{
    int i, n, input[10000], max_value, max_index, sum;
    int age, result = 0, isEnd, l, r, move;
    scanf("%d", &n);
    sum = 0;
    for (i = 0; i < n; i++)
    {
        scanf("%d", &input[i]);
        sum += input[i];
    }
    age = sum / n;
    do
    {
        max_value = -1;
        for (i = 0; i < n; i++)
        {
            if (max(input[i], max_value) != max_value)
            {
                max_value = input[i];
                max_index = i;
            }
        }
        printf("%d-%d\n", max_index, max_value);
        scanf("%d", &i);
        if (max_index == 0)
        {
            move_right(input, age, max_index);
            result++;
            printf("a");
        }
        else if (max_index == n - 1)
        {
            move_left(input, age, max_index);
            result++;
            printf("b");
        }
        else
        {
            for (i = 1; i < n; i++)
            {
                if (max_index - i < 0 && max_index + i >= n)
                {
                    break;
                }
                
                if (max_index - i < 0)
                {
                    move_right(input, age, max_index);
                    result++;
                    break;
                }
                else if (max_index + i > n - 1)
                {
                    move_left(input, age, max_index);
                    result++;
                    break;
                }
                else if (input[max_index - 1] < input[max_index + 1])
                {
                    move_left(input, age, max_index);
                    result++;
                    break;
                }
                else if (input[max_index + 1] < input[max_index - 1])
                {
                    move_right(input, age, max_index);
                    result++;
                    break;
                }
            }
        }

        isEnd = 1;
        for (i = 0; i < n; i++)
        {
            if (input[i] != age)
            {
                isEnd = 0;
            }
        }
    } while (!isEnd);
    printf("%d", result);
    return 0;
}
